home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue52 / Clinic / WebBrowserForm.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-10-19  |  1.2 KB  |  57 lines

  1. unit WebBrowserForm;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   OleCtrls, SHDocVw, StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Browser: TWebBrowser;
  12.     procedure FormCreate(Sender: TObject);
  13.     procedure BrowserBeforeNavigate2(Sender: TObject;
  14.       const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
  15.       Headers: OleVariant; var Cancel: WordBool);
  16.   private
  17.     { Private declarations }
  18.   public
  19.     { Public declarations }
  20.   end;
  21.  
  22. var
  23.   Form1: TForm1;
  24.  
  25. implementation
  26.  
  27. {$R *.DFM}
  28.  
  29. procedure TForm1.FormCreate(Sender: TObject);
  30. begin
  31.   Browser.Navigate('http://localhost/scripts/WebTest.exe')
  32. end;
  33.  
  34. procedure TForm1.BrowserBeforeNavigate2(Sender: TObject;
  35.   const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
  36.   Headers: OleVariant; var Cancel: WordBool);
  37. var
  38.   Tmp: OleVariant;
  39.   S: String;
  40.   P: Pointer;
  41. begin
  42.   Tmp := OleVariant(TVarData(PostData).VPointer^);
  43.   if VarIsArray(Tmp) then
  44.   begin
  45.     SetLength(S, VarArrayHighBound(Tmp, 1) - VarArrayLowBound(Tmp, 1) + 1);
  46.     P := VarArrayLock(Tmp);
  47.     try
  48.       Move(P^, S[1], Length(S));
  49.       Caption := S
  50.     finally
  51.       VarArrayUnlock(Tmp)
  52.     end
  53.   end
  54. end;
  55.  
  56. end.
  57.